;
(function () {
    // @mouseenter="addbgcolor($event, index0)"
    // @mouseleave="removebgcolor"
    Vue.component('tree-org', {
        template: `<div>
    <li v-for="(item0, index0) in model" class="userframework-tree-list" :class="{userpaddingLeft: item0.level < 5}" >
      <div
        class="userframework-title clearfix cursor"
        ref="children"
        @click.stop.prevent="toggle(item0)"
        :data-id="item0.id"
        :data-parentId="item0.parentId"
        :data-type="item0.type"
        :data-index="index0">
        
        <div class="pull-left z-50 relative" id="dd-config">
            <div v-if="showEdit != item0.id" class="ellipsis-1" style="width:125px" :title="item0.shortName">
                <span class="icon---  color-999" :class="showList.indexOf(item0.id) > -1?'icon-GMopen':'icon-Gm-prefix'"  style='margin-right:5px' ></span>
                <span class="user-select" :class="{'user-select-active':item0.select}" @click.stop="selected(item0.memberOrgId,item0)"></span>
                {{item0.shortName}}
            </div>
        </div>
      </div>

      <ul v-if="showList.indexOf(item0.id) > -1">
        <tree-org
          class="item"
          :key="index0"
          @change="getPidData"
          @getdata="getdata"
          ref="children"
          :model="item0.children">
        </tree-org>
      </ul>
    </li>

    </div>`,
        props: {
            model: [Object, Array],
            num: [String]
        },
        data: function () {
            return {
                open: false,
                index: 0,
                data: [],
                status: '',
                kid: null,
                showInput: '',
                newshortName: '',
                newshortName1: '',
                editshortName: '',
                showEdit: '',
                inputType: '',
                showList: [],
                selectIdList: [],
                selectList: [],
                permissions: JSON.parse(window.localStorage.getItem('permissions')),
            }
        },
        methods: {
            //选择当前组织
            selected(id,obj) {
                this.getdata(id,obj)
            },
            //点击展开并且调用下级菜单
            toggle: function (data) {
                if (this.showList.indexOf(data.id) == -1) {
                    this.showList.push(data.id)
                } else {
                    this.showList.splice(this.showList.indexOf(data.id), 1)
                }
                this.getPidData(data.id)
            },
            getPidData(id) {
                this.$emit('change', id)
            },
            getdata(id,obj) {
                this.$emit('getdata', id,obj)
            },
        },
        mounted() {

        }
    })
}())